package mvc.com.controls
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	import mvc.com.events.CustomEvent;
	import mvc.com.utility.Captcha;
		

	public class ControlCaptcha extends MovieClip
	{
		private var controlApp:MovieClip;
		private var mcCaptcha:MovieClip;
		public var clsCaptcha:Captcha;
		private var evtCustom:CustomEvent;		
		
		public function ControlCaptcha($controlApp:MovieClip)
		{
			super();
			this.controlApp=$controlApp;
			mcCaptcha=controlApp.captcha_mc;
			init();
		}
		private function init():void
		{			
			clsCaptcha=new Captcha(mcCaptcha.width,mcCaptcha.height);
			clsCaptcha.initCaptcha();
			mcCaptcha.addChild(clsCaptcha);
			/* Get new captcha */
			mcCaptcha.addEventListener(MouseEvent.CLICK,getNewCaptcha);
		}
		private function getNewCaptcha(evt:MouseEvent):void
		{
			clsCaptcha.initCaptcha();			
			evtCustom=new CustomEvent("onChangeCaptcha");
			evtCustom.captcha=clsCaptcha.getCaptcha();
			dispatchEvent(evtCustom);			
		}
	}
	/* End Class */
}